﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using App.Utilities.Web.Handlers;
using System.Data;
using CRMBiz;
using Newtonsoft.Json;
using CRMWeb.Utilities.Context;

namespace CRMWeb.WebServices
{
    /// <summary>
    /// Summary description for ExtraChecklistItem
    /// </summary>
    public class ExtraChecklistItem : BaseHandler
    {
        public override void OnMethodInvoke(OnMethodInvokeArgs e)
        {
            context.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
            context.Response.Cache.SetExpires(DateTime.MinValue);
            context.Response.Cache.SetNoStore();

            //e.Cancel = true;

            SetResponseContentType(ResponseContentTypes.HTML);
        }

        public override void AfterMethodInvoke(object result)
        {
            base.AfterMethodInvoke(result);
        }

        //user defined function
        #region private method

        public int ExtraChecklistItemAdd(string ItemType, string ItemName, int app_id, int ApplicationContactID, string historyOperator)
        {
            bool flag = false;
            int returnValue = 0;
            try
            {
                //First Check ApplicationContactId which comes is exist in applicationcontact table if yes then only isert/update record.
                DataSet ds= VerificationChecklistHandler.IsExistApplicationContactID(app_id);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    flag = ExtraChecklistItemHandler.AddExtraChecklistItem(ItemType, ItemName, app_id,historyOperator);
                    if (flag)
                        returnValue = ExtraChecklistItemHandler.getLastExtraChecklistItem();
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.saveErrorLog(ex,CMSContext.CurrentUser.MemberName);
            }
            return returnValue;
        }

        #endregion
    }
}